#include "stdafx.h"
#include "sdk_pro.h"
#include "app_sdk_interface.h"
namespace app_sdk {
static const std::string cmd_app_update = "/api.php/index/appUpdate";               // APP更新
static const std::string cmd_send_captcha = "/api.php/common/sendSms";              // 发送短信验证码
static const std::string cmd_register_account = "/api.php/login/register";          // 注册账号
static const std::string cmd_login_account = "/api.php/login/index";                // 登录账号
static const std::string cmd_get_userinfo = "/api.php/user/index";                  // 获取用户信息
static const std::string cmd_user_edit = "/api.php/user/edit";                      // 修改用户信息
static const std::string cmd_recv_redpacket = "/api.php/redpack/receive";           // 领取红包
static const std::string cmd_query_accid = "/api.php/user/search";                  // 查询ACCID
static const std::string cmd_get_chatroomlist = "/api/chatroom/homeList";           // 获取聊天室列表
static const std::string cmd_get_chatroomaddress = "/api/chatroom/requestAddress";  // 获取聊天室连接地址
void SDK_PRO::ResponseBase::Parse(const std::string& response) {
    reply_content_ = response;
    pro_reply_code_ = nim::kNIMResError;
    if (GetResponseCode() == nim::kNIMResSuccess) {
        pro_reply_code_ = nim::kNIMResSuccess;
        OnParse(response);
    }
}
std::string SDK_PRO::ResponseBase::GetReplyContent() const {
    return reply_content_;
}
int32_t SDK_PRO::ResponseBase::GetProtocolReplyCode() const {
    return pro_reply_code_;
}
void SDK_PRO::ResponseBase::SetProtocolReplyCode(int code) {
    pro_reply_code_ = code;
}
void SDK_PRO::ResponseBase::OnParse(const std::string& response){

};
std::string SDK_PRO::RequestBase::GetAPIURL() const {
    if (app_url_.empty())
        app_url_ = OnGetAPIURL();
    return app_url_;
}
std::string SDK_PRO::RequestBase::OnGetAPIURL() const {
    return OnGetHost().append(OnGetAPI());
}
std::string SDK_PRO::RequestBase::OnGetHost() const {
    return AppSDKInterface::GetInstance()->GetAppHost();
}
bool SDK_PRO::RequestBase::UsePostMethod() const {
    return IsUsePostMethod();
}
bool SDK_PRO::RequestBase::IsUsePostMethod() const {
    return true;
}
std::string SDK_PRO::RequestBase::OnGetAPI() const {
    return "";
};
void SDK_PRO::RequestBase::GetRequestContent(std::string& content) const {
    OnGetRequestContent(content);
}
void SDK_PRO::RequestBase::GetRequestHead(std::map<std::string, std::string>& heads) {
    heads["User-Agent"] = "MetaChat-PC";
    heads["appkey"] = AppSDKInterface::GetAppKey();
    heads["charset"] = "utf-8";
    heads["Content-Type"] = "application/json";
    OnGetRequestHead(heads);
}
void SDK_PRO::RequestBase::OnGetRequestContent(std::string& content) const {};
void SDK_PRO::RequestBase::OnGetRequestHead(std::map<std::string, std::string>& heads) const {};
// App更新请求/应答
SDK_PRO::AppUpdateRequest::AppUpdateRequest(std::string platform, std::string token)
    : platform_(platform)
    , token_(token) {}
std::string SDK_PRO::AppUpdateRequest::OnGetHost() const {
    std::string host = __super::OnGetHost();
    std::string new_host = AppSDKInterface::GetInstance()->GetConfigValue("kAppServerAddress");
    if (!new_host.empty()) {
        host = new_host;
    }
    return host;
}
std::string SDK_PRO::AppUpdateRequest::OnGetAPI() const {
    return cmd_app_update;
};
void SDK_PRO::AppUpdateRequest::OnGetRequestHead(std::map<std::string, std::string>& heads) const {
    heads["Content-Type"] = "multipart/form-data; boundary=FormBoundary20230331185230";
}
void SDK_PRO::AppUpdateRequest::OnGetRequestContent(std::string& content) const {
    content.append("--FormBoundary20230331185230\r\n").append("Content-Disposition: form-data; name=\"platform\"\r\n\r\n").append(platform_).append("\r\n");
    content.append("--FormBoundary20230331185230\r\n").append("Content-Disposition: form-data; name=\"token\"\r\n\r\n").append(token_).append("\r\n");
    content.append("--FormBoundary20230331185230\r\n").append("Content-Disposition: form-data; name=\"sign\"\r\n\r\n").append("dev").append("\r\n");
    content.append("--FormBoundary20230331185230--");
}
void SDK_PRO::AppUpdateResponse::OnParse(const std::string& response) {
    Json::Value json_reply;
    Json::Reader reader;
    if (reader.parse(response, json_reply) && json_reply.isObject()) {
        int code = json_reply["code"].asInt();
        SetProtocolReplyCode(code);
        if (code == 0) {
            Json::Value& json_data = json_reply["data"];
            version_ = json_data["version"].asInt();
            subversion_ = json_data["subversion"].asInt();
            versionName_ = json_data["versionNmae"].asString();
            downloadUrl_ = json_data["down"].asString();
            description_ = json_data["description"].asString();
        } else QLOG_ERR(L"Invoke app update error. Json rescode: {0}.") << code;
    }
}
// 发送短信验证码请求/应答
SDK_PRO::SendCaptchaRequest::SendCaptchaRequest(std::string type, std::string mobile, std::string pre)
    : type_(type)
    , mobile_(mobile)
    , pre_(pre) {}
std::string SDK_PRO::SendCaptchaRequest::OnGetHost() const {
    std::string host = __super::OnGetHost();
    std::string new_host = AppSDKInterface::GetInstance()->GetConfigValue("kAppServerAddress");
    if (!new_host.empty()) {
        host = new_host;
    }
    return host;
}
std::string SDK_PRO::SendCaptchaRequest::OnGetAPI() const {
    return cmd_send_captcha;
};
void SDK_PRO::SendCaptchaRequest::OnGetRequestHead(std::map<std::string, std::string>& heads) const {
    heads["Content-Type"] = "multipart/form-data; boundary=FormBoundary20230224193020";
}
void SDK_PRO::SendCaptchaRequest::OnGetRequestContent(std::string& content) const {
    content.append("--FormBoundary20230224193020\r\n").append("Content-Disposition: form-data; name=\"type\"\r\n\r\n").append(type_).append("\r\n");
    content.append("--FormBoundary20230224193020\r\n").append("Content-Disposition: form-data; name=\"mobile\"\r\n\r\n").append(mobile_).append("\r\n");
    content.append("--FormBoundary20230224193020\r\n").append("Content-Disposition: form-data; name=\"pre\"\r\n\r\n").append(pre_).append("\r\n");
    content.append("--FormBoundary20230224193020\r\n").append("Content-Disposition: form-data; name=\"sign\"\r\n\r\n").append("dev").append("\r\n");
    content.append("--FormBoundary20230224193020--");
}
void SDK_PRO::SendCaptchaResponse::OnParse(const std::string& response) {
    Json::Value json_reply;
    Json::Reader reader;
    if (reader.parse(response, json_reply) && json_reply.isObject()) {
        int code = json_reply["code"].asInt();
        if (json_reply.isMember("msg")) msg_ = json_reply["msg"].asString();
        SetProtocolReplyCode(code);
        if (code != 0) {
            QLOG_ERR(L"Invoke send code error. Json rescode: {0}.") << code;
        }
    }
}
// 注册账号请求/应答
SDK_PRO::RegisterAccountRequest::RegisterAccountRequest(std::string mobile,
                                                        std::string pre,
                                                        std::string password,
                                                        std::string code,
                                                        std::string nickname,
                                                        std::string deviceid)
    : mobile_(mobile)
    , pre_(pre)
    , password_(password)
    , code_(code)
    , nickname_(nickname)
    , deviceid_(deviceid) {}
std::string SDK_PRO::RegisterAccountRequest::OnGetHost() const {
    std::string host = __super::OnGetHost();
    std::string new_host = AppSDKInterface::GetInstance()->GetConfigValue("kAppServerAddress");
    if (!new_host.empty()) {
        host = new_host;
    }
    return host;
}
std::string SDK_PRO::RegisterAccountRequest::OnGetAPI() const {
    return cmd_register_account;
};
void SDK_PRO::RegisterAccountRequest::OnGetRequestHead(std::map<std::string, std::string>& heads) const {
    heads["Content-Type"] = "multipart/form-data; boundary=FormBoundary20230224194010";
}
void SDK_PRO::RegisterAccountRequest::OnGetRequestContent(std::string& content) const {
    content.append("--FormBoundary20230224194010\r\n").append("Content-Disposition: form-data; name=\"mobile\"\r\n\r\n").append(mobile_).append("\r\n");
    content.append("--FormBoundary20230224194010\r\n").append("Content-Disposition: form-data; name=\"pre\"\r\n\r\n").append(pre_).append("\r\n");
    content.append("--FormBoundary20230224194010\r\n").append("Content-Disposition: form-data; name=\"password\"\r\n\r\n").append(password_).append("\r\n");
    //content.append("--FormBoundary20230224194010\r\n").append("Content-Disposition: form-data; name=\"code\"\r\n\r\n").append(code_).append("\r\n");
    content.append("--FormBoundary20230224194010\r\n").append("Content-Disposition: form-data; name=\"nickname\"\r\n\r\n").append(nickname_).append("\r\n");
    content.append("--FormBoundary20230224194010\r\n").append("Content-Disposition: form-data; name=\"deviceid\"\r\n\r\n").append(deviceid_).append("\r\n");
    content.append("--FormBoundary20230224194010\r\n").append("Content-Disposition: form-data; name=\"sign\"\r\n\r\n").append("dev").append("\r\n");
    content.append("--FormBoundary20230224194010--");
}
void SDK_PRO::RegisterAccountResponse::OnParse(const std::string& response) {
    Json::Value json_reply;
    Json::Reader reader;
    if (reader.parse(response, json_reply) && json_reply.isObject()) {
        int code = json_reply["code"].asInt();
        if (json_reply.isMember("msg")) msg_ = json_reply["msg"].asString();
        SetProtocolReplyCode(code);
        if (code != 0) {
            QLOG_ERR(L"Invoke register account error. Json rescode: {0}.") << code;
        }
    }
}
// 登录账号请求/应答
SDK_PRO::LoginAccountRequest::LoginAccountRequest(std::string account,
                                                  std::string password,
                                                  std::string deviceid)
    : account_(account)
    , password_(password)
    , deviceid_(deviceid) {}
std::string SDK_PRO::LoginAccountRequest::OnGetHost() const {
    std::string host = __super::OnGetHost();
    std::string new_host = AppSDKInterface::GetInstance()->GetConfigValue("kAppServerAddress");
    if (!new_host.empty()) {
        host = new_host;
    }
    return host;
}
std::string SDK_PRO::LoginAccountRequest::OnGetAPI() const {
    return cmd_login_account;
};
void SDK_PRO::LoginAccountRequest::OnGetRequestHead(std::map<std::string, std::string>& heads) const {
    heads["Content-Type"] = "multipart/form-data; boundary=FormBoundary20230224201112";
}
void SDK_PRO::LoginAccountRequest::OnGetRequestContent(std::string& content) const {
    content.append("--FormBoundary20230224201112\r\n").append("Content-Disposition: form-data; name=\"account\"\r\n\r\n").append(account_).append("\r\n");
    content.append("--FormBoundary20230224201112\r\n").append("Content-Disposition: form-data; name=\"password\"\r\n\r\n").append(password_).append("\r\n");
    content.append("--FormBoundary20230224201112\r\n").append("Content-Disposition: form-data; name=\"deviceid\"\r\n\r\n").append(deviceid_).append("\r\n");
    content.append("--FormBoundary20230224201112\r\n").append("Content-Disposition: form-data; name=\"sign\"\r\n\r\n").append("dev").append("\r\n");
    content.append("--FormBoundary20230224201112--");
}
void SDK_PRO::LoginAccountResponse::OnParse(const std::string& response) {
    Json::Value json_reply;
    Json::Reader reader;
    if (reader.parse(response, json_reply) && json_reply.isObject()) {
        int code = json_reply["code"].asInt();
        if (json_reply.isMember("msg")) msg_ = json_reply["msg"].asString();
        SetProtocolReplyCode(code);
        if (code == 0) {
            Json::Value& json_data = json_reply["data"];
            token_ = json_data["token"].asString();
            Json::Value& data_user = json_data["user"];
            accid_ = data_user["accid"].asString();
            yxToken_ = data_user["yxToken"].asString();
            avatar_ = data_user["avatar"].asString();
            nickname_ = data_user["nickname"].asString();
            user_id_ = data_user["user_id"].asInt();
        } else QLOG_ERR(L"Invoke login account error. Json rescode: {0}.") << code;
    }
}
// 获取用户信息请求/应答
SDK_PRO::GetUserInfoRequest::GetUserInfoRequest(std::string token) : token_(token) {}
std::string SDK_PRO::GetUserInfoRequest::OnGetHost() const {
    std::string host = __super::OnGetHost();
    std::string new_host = AppSDKInterface::GetInstance()->GetConfigValue("kAppServerAddress");
    if (!new_host.empty()) {
        host = new_host;
    }
    return host;
}
std::string SDK_PRO::GetUserInfoRequest::OnGetAPI() const {
    return cmd_get_userinfo;
};
void SDK_PRO::GetUserInfoRequest::OnGetRequestHead(std::map<std::string, std::string>& heads) const {
    heads["Content-Type"] = "multipart/form-data; boundary=FormBoundary20230308210730";
}
void SDK_PRO::GetUserInfoRequest::OnGetRequestContent(std::string& content) const {
    content.append("--FormBoundary20230308210730\r\n").append("Content-Disposition: form-data; name=\"token\"\r\n\r\n").append(token_).append("\r\n");
    content.append("--FormBoundary20230308210730\r\n").append("Content-Disposition: form-data; name=\"sign\"\r\n\r\n").append("dev").append("\r\n");
    content.append("--FormBoundary20230308210730--");
}
void SDK_PRO::GetUserInfoResponse::OnParse(const std::string& response) {
    Json::Value json_reply;
    Json::Reader reader;
    if (reader.parse(response, json_reply) && json_reply.isObject()) {
        int code = json_reply["code"].asInt();
        SetProtocolReplyCode(code);
        if (code == 0) {
            Json::Value& json_data = json_reply["data"];
            account_ = json_data["account"].asString();
            username_ = json_data["username"].asString();
            pre_ = json_data["pre"].asString();
            mobile_ = json_data["mobile"].asString();
            nickname_ = json_data["nickname"].asString();
            //gode_ = json_data["gode"].asString();
            //baye_ = json_data["baye"].asString();
        } else QLOG_ERR(L"Invoke user info error. Json rescode: {0}.") << code;
    }
}
// 修改用户信息请求/应答
SDK_PRO::UserEditRequest::UserEditRequest(std::string token,
    std::string signature,
    std::string nickname,
    std::string avatar)
    : token_(token)
    , signature_(signature)
    , nickname_(nickname)
    , avatar_(avatar) {}
std::string SDK_PRO::UserEditRequest::OnGetHost() const {
    std::string host = __super::OnGetHost();
    std::string new_host = AppSDKInterface::GetInstance()->GetConfigValue("kAppServerAddress");
    if (!new_host.empty()) {
        host = new_host;
    }
    return host;
}
std::string SDK_PRO::UserEditRequest::OnGetAPI() const {
    return cmd_user_edit;
};
void SDK_PRO::UserEditRequest::OnGetRequestHead(std::map<std::string, std::string>& heads) const {
    heads["Content-Type"] = "multipart/form-data; boundary=FormBoundary20240224194010";
}
void SDK_PRO::UserEditRequest::OnGetRequestContent(std::string& content) const {
    content.append("--FormBoundary20240224194010\r\n").append("Content-Disposition: form-data; name=\"token\"\r\n\r\n").append(token_).append("\r\n");
    if (!signature_.empty()) content.append("--FormBoundary20240224194010\r\n").append("Content-Disposition: form-data; name=\"signature\"\r\n\r\n").append(signature_).append("\r\n");
    if (!nickname_.empty()) content.append("--FormBoundary20240224194010\r\n").append("Content-Disposition: form-data; name=\"nickname\"\r\n\r\n").append(nickname_).append("\r\n");
    if (!avatar_.empty()) content.append("--FormBoundary20240224194010\r\n").append("Content-Disposition: form-data; name=\"avatar\"\r\n\r\n").append(avatar_).append("\r\n");
    content.append("--FormBoundary20240224194010\r\n").append("Content-Disposition: form-data; name=\"sign\"\r\n\r\n").append("dev").append("\r\n");
    content.append("--FormBoundary20240224194010--");
}
void SDK_PRO::UserEditResponse::OnParse(const std::string& response) {
    Json::Value json_reply;
    Json::Reader reader;
    if (reader.parse(response, json_reply) && json_reply.isObject()) {
        int code = json_reply["code"].asInt();
        if (json_reply.isMember("msg")) msg_ = json_reply["msg"].asString();
        SetProtocolReplyCode(code);
        if (code != 0) {
            QLOG_ERR(L"Invoke register account error. Json rescode: {0}.") << code;
        }
    }
}
// 领取红包请求/应答
SDK_PRO::ReceiveRedPacketRequest::ReceiveRedPacketRequest(std::string token,
                                                          std::string pack_id,
                                                          std::string tid)
    : token_(token)
    , pack_id_(pack_id)
    , tid_(tid)
    , type_(tid.empty() ? 0 : 1) {}
std::string SDK_PRO::ReceiveRedPacketRequest::OnGetHost() const {
    std::string host = __super::OnGetHost();
    std::string new_host = AppSDKInterface::GetInstance()->GetConfigValue("kAppServerAddress");
    if (!new_host.empty()) {
        host = new_host;
    }
    return host;
}
std::string SDK_PRO::ReceiveRedPacketRequest::OnGetAPI() const {
    return cmd_recv_redpacket;
};
void SDK_PRO::ReceiveRedPacketRequest::OnGetRequestHead(std::map<std::string, std::string>& heads) const {
    heads["Content-Type"] = "multipart/form-data; boundary=FormBoundary20230310212102";
}
void SDK_PRO::ReceiveRedPacketRequest::OnGetRequestContent(std::string& content) const {
    content.append("--FormBoundary20230310212102\r\n").append("Content-Disposition: form-data; name=\"token\"\r\n\r\n").append(token_).append("\r\n");
    content.append("--FormBoundary20230310212102\r\n").append("Content-Disposition: form-data; name=\"pack_id\"\r\n\r\n").append(pack_id_).append("\r\n");
    content.append("--FormBoundary20230310212102\r\n").append("Content-Disposition: form-data; name=\"type\"\r\n\r\n").append(std::to_string(type_)).append("\r\n");
    content.append("--FormBoundary20230310212102\r\n").append("Content-Disposition: form-data; name=\"tid\"\r\n\r\n").append(tid_).append("\r\n");
    content.append("--FormBoundary20230310212102\r\n").append("Content-Disposition: form-data; name=\"sign\"\r\n\r\n").append("dev").append("\r\n");
    content.append("--FormBoundary20230310212102--");
}
void SDK_PRO::ReceiveRedPacketResponse::OnParse(const std::string& response) {
    Json::Value json_reply;
    Json::Reader reader;
    if (reader.parse(response, json_reply) && json_reply.isObject()) {
        int code = json_reply["code"].asInt();
        msg_ = json_reply["msg"].asString();
        SetProtocolReplyCode(code);
        if (code == 0) {
            Json::Value& json_data = json_reply["data"];
            amount_type_ = json_data["amount_type"].asString();
            amount_ = json_data["amount"].asString();
        }
        else QLOG_ERR(L"Invoke recv redpacket error. Json rescode: {0}.") << code;
    }
}
// 查询ACCID请求/应答
SDK_PRO::QueryAccidRequest::QueryAccidRequest(std::string token,
    std::string keyword)
    : token_(token)
    , keyword_(keyword) {}
std::string SDK_PRO::QueryAccidRequest::OnGetHost() const {
    std::string host = __super::OnGetHost();
    std::string new_host = AppSDKInterface::GetInstance()->GetConfigValue("kAppServerAddress");
    if (!new_host.empty()) {
        host = new_host;
    }
    return host;
}
std::string SDK_PRO::QueryAccidRequest::OnGetAPI() const {
    return cmd_query_accid;
};
void SDK_PRO::QueryAccidRequest::OnGetRequestHead(std::map<std::string, std::string>& heads) const {
    heads["Content-Type"] = "multipart/form-data; boundary=FormBoundary20230331210630";
}
void SDK_PRO::QueryAccidRequest::OnGetRequestContent(std::string& content) const {
    content.append("--FormBoundary20230331210630\r\n").append("Content-Disposition: form-data; name=\"token\"\r\n\r\n").append(token_).append("\r\n");
    content.append("--FormBoundary20230331210630\r\n").append("Content-Disposition: form-data; name=\"keyword\"\r\n\r\n").append(keyword_).append("\r\n");
    content.append("--FormBoundary20230331210630\r\n").append("Content-Disposition: form-data; name=\"sign\"\r\n\r\n").append("dev").append("\r\n");
    content.append("--FormBoundary20230331210630--");
}
void SDK_PRO::QueryAccidResponse::OnParse(const std::string& response) {
    Json::Value json_reply;
    Json::Reader reader;
    if (reader.parse(response, json_reply) && json_reply.isObject()) {
        int code = json_reply["code"].asInt();
        msg_ = json_reply["msg"].asString();
        SetProtocolReplyCode(code);
        if (code == 0) {
            Json::Value& json_data = json_reply["data"];
            accid_ = json_data["accid"].asString();
        } else QLOG_ERR(L"Invoke recv redpacket error. Json rescode: {0}.") << code;
    }
}
// 获取聊天室列表请求/应答
std::string SDK_PRO::GetChatroomListRequest::OnGetAPI() const {
    return cmd_get_chatroomlist;
};
std::string SDK_PRO::GetChatroomListRequest::OnGetAPIURL() const {
    std::string api_addr = __super::OnGetAPIURL();
    std::string new_api_addr = AppSDKInterface::GetInstance()->GetConfigValue("kNIMChatRoomAddress");
    if (!new_api_addr.empty())
        api_addr = new_api_addr;
    return api_addr;
}
bool SDK_PRO::GetChatroomListRequest::IsUsePostMethod() const {
    return false;
}
void SDK_PRO::GetChatroomListResponse::OnParse(const std::string& response) {
    Json::Value json_reply;
    Json::Reader reader;
    if (reader.parse(response, json_reply) && json_reply.isObject()) {
        int res = json_reply["res"].asInt();
        if (res != nim::kNIMResSuccess) {
            this->SetProtocolReplyCode(res);
            QLOG_ERR(L"Invoke get room list error. Json rescode: {0}.") << res;
            return;
        }
        if (!json_reply["msg"]["list"].isArray()) {
            QLOG_ERR(L"Invoke get room list error. Reason: Not an array.");
            return;
        }
        for (auto it : json_reply["msg"]["list"]) {
            nim_chatroom::ChatRoomInfo info;
            info.id_ = it["roomid"].asInt64();
            info.name_ = it["name"].asString();
            info.creator_id_ = it["creator"].asString();
            nbase::StringToInt(it["onlineusercount"].asString(), &info.online_count_);
            info.valid_flag_ = it["status"].asInt();
            info.ext_ = it["ext"].asString();
            info.announcement_ = it["announcement"].asString();
            info.broadcast_url_ = it["broadcasturl"].asString();
            chatroom_list_.emplace_back(info);
        }
    }
};
// 获取聊天室连接地址请求/应答
SDK_PRO::GetChatroomAddressRequest::GetChatroomAddressRequest()
    : type_(2)
    , uid_("")
    , room_id_(0) {}
std::string SDK_PRO::GetChatroomAddressRequest::OnGetAPIURL() const {
    std::string api_addr = __super::OnGetAPIURL();
    std::string new_api_addr = AppSDKInterface::GetInstance()->GetConfigValue("kNIMChatRoomRequest");
    if (!new_api_addr.empty())
        api_addr = new_api_addr;
    return api_addr;
}
std::string SDK_PRO::GetChatroomAddressRequest::OnGetAPI() const {
    return cmd_get_chatroomaddress;
}
void SDK_PRO::GetChatroomAddressRequest::OnGetRequestContent(std::string& content) const {
    Json::Value data;
    Json::FastWriter fs;
    data["roomid"] = room_id_;
    data["uid"] = uid_;
    data["type"] = type_;
    content = fs.write(data);
}
void SDK_PRO::GetChatroomAddressResponse::OnParse(const std::string& response) {
    Json::Value json_reply;
    Json::Reader reader;
    if (reader.parse(response, json_reply) && json_reply.isObject()) {
        int res = json_reply["res"].asInt();
        if (res != nim::kNIMResSuccess) {
            this->SetProtocolReplyCode(res);
            QLOG_ERR(L"Invoke get room address error. Json rescode: {0}.") << res;
            return;
        }
        if (!json_reply["msg"]["addr"].isArray()) {
            QLOG_ERR(L"Invoke get room address error. Reason: Not an array.");
            return;
        }
        for (auto it : json_reply["msg"]["addr"]) {
            address_.emplace_back(it.asString());
        }
    }
}
}  // namespace app_sdk